digest: add dev::initialized_mac_test function#2367
Merged
newpavlov merged 3 commits intoRustCrypto:masterfrom Apr 7, 2026
Merged
digest: add dev::initialized_mac_test function#2367newpavlov merged 3 commits intoRustCrypto:masterfrom
dev::initialized_mac_test function#2367newpavlov merged 3 commits intoRustCrypto:masterfrom
Conversation
newpavlov
reviewed
Apr 6, 2026
Member
newpavlov
left a comment
There was a problem hiding this comment.
Looks good, but I would name the test something like initialized_mac_test for better clarity.
Contributor
Author
Done. It just occurred to me. Should I also bump the patch/minor version for this package? |
Member
No, we usually do it in release PRs. |
dev::initialized_mac_test function
newpavlov
approved these changes
Apr 7, 2026
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a prerequisite of implementing GMAC in RustCrypto/MACs#1
As GMAC is nonce-based it cannot implement KeyInit and thus the current
mac_testfunction cannot work for it. However, it doesn't make sense to build significant logic for a single special MAC. So, this breaksmac_testinto two parts:mac_test) that constructs a Mac that implementsKeyInitand then passes it toraw_mac_test.raw_mac_testwhich is what actually does the testing but simply clones the supplied MAC.This way all "normal" MACs can keep being tested the same way they always have but "special" MACs can take advantage of the shared test logic.
I did not modify
reset_mac_testbecause nonce-based MACs like GMAC cannot be safely reset, so the refactoring would not have been worth it.I am not passing in the existing
MacTestVectorstructure, because it isn't applicable to nonce-based MACs and we only needinputandtagso they are easy enough to pass independently.I have manually tested this by redirecting the
cmactests to use my local changes. I also had my newgmactests use the new logic successfully.